/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

package scenic;

import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

import scenic.jni.Renderer;

/**
 * Applies a color space to the sub-graph. All rendering in the sub-graph 
 * is done in the specified color space. Currently experimental, do not use.
 */
public class SceneColorSpace extends SceneContainer {
	void draw(DrawContext context, AffineTransform transform, Rectangle visibleArea) {
		Rectangle bounds = getBounds(context, transform);
			
		if(bounds.width <= 0 || bounds.height <= 0)
			return;
		bounds = addSafetyMargin(bounds);
		if(context.renderer.beginSurface(context.context, bounds, Renderer.SURFACE_TYPE_COLOR) == 0)
			return;
		context.renderer.setColorSpace(context.context, true);
		super.draw(context, transform, bounds);
		context.renderer.color(context.context, 1.0f, 1.0f, 1.0f, 1.0f);
		context.renderer.drawSurface(context.context);
	}
	
	Rectangle getBounds(DrawContext context, AffineTransform transform) {
		Rectangle result = super.getBounds(context, transform);

		return result;
	}
	
}
